home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / PInterfaces / Printing.p < prev    next >
Encoding:
Text File  |  1994-07-21  |  13.3 KB  |  486 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Printing.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.1  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT Printing;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __PRINTING__}
  27. {$SETC __PRINTING__ := 1}
  28.  
  29. {$I+}
  30. {$SETC PrintingIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __ERRORS__}
  35. {$I Errors.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __QUICKDRAW__}
  40. {$I Quickdraw.p}
  41. {$ENDC}
  42. {    Types.p                                                        }
  43. {    MixedMode.p                                                    }
  44. {    QuickdrawText.p                                                }
  45.  
  46. {$IFC UNDEFINED __DIALOGS__}
  47. {$I Dialogs.p}
  48. {$ENDC}
  49. {    Memory.p                                                    }
  50. {    Windows.p                                                    }
  51. {        Events.p                                                }
  52. {            OSUtils.p                                            }
  53. {        Controls.p                                                }
  54. {            Menus.p                                                }
  55. {    TextEdit.p                                                    }
  56.  
  57. {$PUSH}
  58. {$ALIGN MAC68K}
  59. {$LibExport+}
  60.  
  61. CONST
  62.     iPFMaxPgs                    = 128;
  63.     iPrPgFract                    = 120;                            {Page scale factor. ptPgSize (below) is in units of 1/iPrPgFract}
  64.     iPrPgFst                    = 1;                            {Page range constants}
  65.     iPrPgMax                    = 9999;
  66.     iPrRelease                    = 3;                            {Current version number of the code.}
  67.     iPrSavPFil                    = -1;
  68.     iPrAbort                    = $0080;
  69.     iPrDevCtl                    = 7;                            {The PrDevCtl Proc's ctl number}
  70.     lPrReset                    = $00010000;                    {The PrDevCtl Proc's CParam for reset}
  71.     lPrLineFeed                    = $00030000;
  72.     lPrLFStd                    = $0003FFFF;                    {The PrDevCtl Proc's CParam for std paper advance}
  73.     lPrLFSixth                    = $0003FFFF;
  74.     lPrPageEnd                    = $00020000;                    {The PrDevCtl Proc's CParam for end page}
  75.     lPrDocOpen                    = $00010000;
  76.     lPrPageOpen                    = $00040000;
  77.     lPrPageClose                = $00020000;
  78.     lPrDocClose                    = $00050000;
  79.     iFMgrCtl                    = 8;                            {The FMgr's Tail-hook Proc's ctl number}
  80.     iMscCtl                        = 9;                            {The FMgr's Tail-hook Proc's ctl number}
  81.     iPvtCtl                        = 10;                            {The FMgr's Tail-hook Proc's ctl number}
  82.  
  83.     pPrGlobals                    = $00000944;                    {The PrVars lo mem area:}
  84.     bDraftLoop                    = 0;
  85.     bSpoolLoop                    = 1;
  86.     bUser1Loop                    = 2;
  87.     bUser2Loop                    = 3;
  88.     fNewRunBit                    = 2;
  89.     fHiResOK                    = 3;
  90.     fWeOpenedRF                    = 4;
  91. {Driver constants }
  92.     iPrBitsCtl                    = 4;
  93.     lScreenBits                    = 0;
  94.     lPaintBits                    = 1;
  95.     lHiScreenBits                = $00000002;                    {The Bitmap Print Proc's Screen Bitmap param}
  96.     lHiPaintBits                = $00000003;                    {The Bitmap Print Proc's Paint [sq pix] param}
  97.     iPrIOCtl                    = 5;
  98.     iPrEvtCtl                    = 6;                            {The PrEvent Proc's ctl number}
  99.     lPrEvtAll                    = $0002FFFD;                    {The PrEvent Proc's CParam for the entire screen}
  100.     lPrEvtTop                    = $0001FFFD;                    {The PrEvent Proc's CParam for the top folder}
  101.     iPrDrvrRef                    = -3;
  102.  
  103.     getRslDataOp                = 4;
  104.     setRslOp                    = 5;
  105.     draftBitsOp                    = 6;
  106.     noDraftBitsOp                = 7;
  107.     getRotnOp                    = 8;
  108.     NoSuchRsl                    = 1;
  109.     OpNotImpl                    = 2;                            {the driver doesn't support this opcode}
  110.     RgType1                        = 1;
  111.  
  112.     feedCut                        = 0;
  113.     feedFanfold                    = 1;
  114.     feedMechCut                    = 2;
  115.     feedOther                    = 3;
  116.  
  117.     
  118. TYPE
  119. TFeed = SInt8;
  120.  
  121.  
  122. CONST
  123.     scanTB                        = 0;
  124.     scanBT                        = 1;
  125.     scanLR                        = 2;
  126.     scanRL                        = 3;
  127.  
  128.     
  129. TYPE
  130. TScan = SInt8;
  131.  
  132. { A Rect Ptr }
  133.     TPRect = ^Rect;
  134.  
  135.     PrIdleProcPtr = ProcPtr;  { PROCEDURE PrIdle; }
  136.     PrIdleUPP = UniversalProcPtr;
  137.  
  138. CONST
  139.     uppPrIdleProcInfo = $00000000; { PROCEDURE ; }
  140.  
  141. FUNCTION NewPrIdleProc(userRoutine: PrIdleProcPtr): PrIdleUPP;
  142.     {$IFC NOT GENERATINGCFM }
  143.     INLINE $2E9F;
  144.     {$ENDC}
  145.  
  146. PROCEDURE CallPrIdleProc(userRoutine: PrIdleUPP);
  147.     {$IFC NOT GENERATINGCFM}
  148.     INLINE $205F, $4E90;
  149.     {$ENDC}
  150. TYPE
  151.     PItemProcPtr = ProcPtr;  { PROCEDURE PItem(theDialog: DialogPtr; item: INTEGER); }
  152.     PItemUPP = UniversalProcPtr;
  153.  
  154. CONST
  155.     uppPItemProcInfo = $000002C0; { PROCEDURE (4 byte param, 2 byte param); }
  156.  
  157. FUNCTION NewPItemProc(userRoutine: PItemProcPtr): PItemUPP;
  158.     {$IFC NOT GENERATINGCFM }
  159.     INLINE $2E9F;
  160.     {$ENDC}
  161.  
  162. PROCEDURE CallPItemProc(theDialog: DialogPtr; item: INTEGER; userRoutine: PItemUPP);
  163.     {$IFC NOT GENERATINGCFM}
  164.     INLINE $205F, $4E90;
  165.     {$ENDC}
  166.  
  167. TYPE
  168.     TPrPort = RECORD
  169.         gPort:                    GrafPort;                                {The Printer's graf port.}
  170.         gProcs:                    QDProcs;                                {..and its procs}
  171.         lGParam1:                LONGINT;                                {16 bytes for private parameter storage.}
  172.         lGParam2:                LONGINT;
  173.         lGParam3:                LONGINT;
  174.         lGParam4:                LONGINT;
  175.         fOurPtr:                BOOLEAN;                                {Whether the PrPort allocation was done by us.}
  176.         fOurBits:                BOOLEAN;                                {Whether the BitMap allocation was done by us.}
  177.     END;
  178.     TPPrPort = ^TPrPort;
  179.  
  180. { Printing Graf Port. All printer imaging, whether spooling, banding, etc, happens "thru" a GrafPort.
  181.   This is the "PrPeek" record. }
  182.     TPrInfo = RECORD
  183.         iDev:                    INTEGER;                                {Font mgr/QuickDraw device code}
  184.         iVRes:                    INTEGER;                                {Resolution of device, in device coordinates}
  185.         iHRes:                    INTEGER;                                {..note: V before H => compatable with Point.}
  186.         rPage:                    Rect;                                    {The page (printable) rectangle in device coordinates.}
  187.     END;
  188.     TPPrInfo = ^TPrInfo;
  189.  
  190. { Print Info Record: The parameters needed for page composition. }
  191.     TPrStl = RECORD
  192.         wDev:                    INTEGER;
  193.         iPageV:                    INTEGER;
  194.         iPageH:                    INTEGER;
  195.         bPort:                    SInt8;
  196.         feed:                    TFeed;
  197.     END;
  198.     TPPrStl = ^TPrStl;
  199.  
  200.     TPrXInfo = RECORD
  201.         iRowBytes:                INTEGER;
  202.         iBandV:                    INTEGER;
  203.         iBandH:                    INTEGER;
  204.         iDevBytes:                INTEGER;
  205.         iBands:                    INTEGER;
  206.         bPatScale:                SInt8;
  207.         bUlThick:                SInt8;
  208.         bUlOffset:                SInt8;
  209.         bUlShadow:                SInt8;
  210.         scan:                    TScan;
  211.         bXInfoX:                SInt8;
  212.     END;
  213.     TPPrXInfo = ^TPrXInfo;
  214.  
  215.     TPrJob = RECORD
  216.         iFstPage:                INTEGER;                                {Page Range.}
  217.         iLstPage:                INTEGER;
  218.         iCopies:                INTEGER;                                {No. copies.}
  219.         bJDocLoop:                SInt8;                                    {The Doc style: Draft, Spool, .., and ..}
  220.         fFromUsr:                BOOLEAN;                                {Printing from an User's App (not PrApp) flag}
  221.         pIdleProc:                PrIdleUPP;                                {The Proc called while waiting on IO etc.}
  222.         pFileName:                StringPtr;                                {Spool File Name: NIL for default.}
  223.         iFileVol:                INTEGER;                                {Spool File vol, set to 0 initially}
  224.         bFileVers:                SInt8;                                    {Spool File version, set to 0 initially}
  225.         bJobX:                    SInt8;                                    {An eXtra byte.}
  226.     END;
  227.     TPPrJob = ^TPrJob;
  228.  
  229. { Print Job: Print "form" for a single print request. }
  230.     TPrFlag1 = PACKED RECORD
  231.         f15:                    BOOLEAN;
  232.         f14:                    BOOLEAN;
  233.         f13:                    BOOLEAN;
  234.         f12:                    BOOLEAN;
  235.         f11:                    BOOLEAN;
  236.         f10:                    BOOLEAN;
  237.         f9:                        BOOLEAN;
  238.         f8:                        BOOLEAN;
  239.         f7:                        BOOLEAN;
  240.         f6:                        BOOLEAN;
  241.         f5:                        BOOLEAN;
  242.         f4:                        BOOLEAN;
  243.         f3:                        BOOLEAN;
  244.         f2:                        BOOLEAN;
  245.         fLstPgFst:                BOOLEAN;
  246.         fUserScale:                BOOLEAN;
  247.     END;
  248.     TPrint = RECORD
  249.         iPrVersion:                INTEGER;                                {(2) Printing software version}
  250.         prInfo:                    TPrInfo;                                {(14) the PrInfo data associated with the current style.}
  251.         rPaper:                    Rect;                                    {(8) The paper rectangle [offset from rPage]}
  252.         prStl:                    TPrStl;                                    {(8)  This print request's style.}
  253.         prInfoPT:                TPrInfo;                                {(14)  Print Time Imaging metrics}
  254.         prXInfo:                TPrXInfo;                                {(16)  Print-time (expanded) Print info record.}
  255.         prJob:                    TPrJob;                                    {(20) The Print Job request (82)  Total of the above; 120-82 = 38 bytes needed to fill 120}
  256.         CASE INTEGER OF
  257.         0: (
  258.             printX:                        ARRAY [0..18] OF INTEGER;
  259.            );
  260.         1: (
  261.             prFlag1:                    TPrFlag1;
  262.             iZoomMin:                    INTEGER;
  263.             iZoomMax:                    INTEGER;
  264.             hDocName:                    StringHandle;
  265.            );
  266.     END;
  267.  
  268.     TPPrint = ^TPrint;
  269.     THPrint = ^TPPrint;
  270.  
  271. { The universal 120 byte printing record }
  272.     TPrStatus = RECORD
  273.         iTotPages:                INTEGER;                                {Total pages in Print File.}
  274.         iCurPage:                INTEGER;                                {Current page number}
  275.         iTotCopies:                INTEGER;                                {Total copies requested}
  276.         iCurCopy:                INTEGER;                                {Current copy number}
  277.         iTotBands:                INTEGER;                                {Total bands per page.}
  278.         iCurBand:                INTEGER;                                {Current band number}
  279.         fPgDirty:                BOOLEAN;                                {True if current page has been written to.}
  280.         fImaging:                BOOLEAN;                                {Set while in band's DrawPic call.}
  281.         hPrint:                    THPrint;                                {Handle to the active Printer record}
  282.         pPrPort:                TPPrPort;                                {Ptr to the active PrPort}
  283.         hPic:                    PicHandle;                                {Handle to the active Picture}
  284.     END;
  285.     TPPrStatus = ^TPrStatus;
  286.  
  287. { Print Status: Print information during printing. }
  288.     TPfPgDir = RECORD
  289.         iPages:                    INTEGER;
  290.         iPgPos:                    ARRAY [0..128] OF LONGINT;                {ARRAY [0..iPfMaxPgs] OF LONGINT}
  291.     END;
  292.     TPPfPgDir = ^TPfPgDir;
  293.     THPfPgDir = ^TPPfPgDir;
  294.  
  295. { PicFile = a TPfHeader followed by n QuickDraw Pics (whose PicSize is invalid!) }
  296.     TPrDlg = RECORD
  297.         Dlg:                    DialogRecord;                            {The Dialog window}
  298.         pFltrProc:                ModalFilterUPP;                            {The Filter Proc.}
  299.         pItemProc:                PItemUPP;                                {The Item evaluating proc.}
  300.         hPrintUsr:                THPrint;                                {The user's print record.}
  301.         fDoIt:                    BOOLEAN;
  302.         fDone:                    BOOLEAN;
  303.         lUser1:                    LONGINT;                                {Four longs for user's to hang global data.}
  304.         lUser2:                    LONGINT;                                {...Plus more stuff needed by the particular printing dialog.}
  305.         lUser3:                    LONGINT;
  306.         lUser4:                    LONGINT;
  307.     END;
  308.     TPPrDlg = ^TPrDlg;
  309.  
  310.     PDlgInitProcPtr = ProcPtr;  { FUNCTION PDlgInit(hPrint: THPrint): TPPrDlg; }
  311.     PDlgInitUPP = UniversalProcPtr;
  312.  
  313. CONST
  314.     uppPDlgInitProcInfo = $000000F0; { FUNCTION (4 byte param): 4 byte result; }
  315.  
  316. FUNCTION NewPDlgInitProc(userRoutine: PDlgInitProcPtr): PDlgInitUPP;
  317.     {$IFC NOT GENERATINGCFM }
  318.     INLINE $2E9F;
  319.     {$ENDC}
  320.  
  321. FUNCTION CallPDlgInitProc(hPrint: THPrint; userRoutine: PDlgInitUPP): TPPrDlg;
  322.     {$IFC NOT GENERATINGCFM}
  323.     INLINE $205F, $4E90;
  324.     {$ENDC}
  325. { This is the Printing Dialog Record. Only used by folks appending their own dialogs.
  326. Print Dialog: The Dialog Stream object. }
  327.  
  328. TYPE
  329.     TGnlData = RECORD
  330.         iOpCode:                INTEGER;
  331.         iError:                    INTEGER;
  332.         lReserved:                LONGINT;                                {more fields here depending on call}
  333.     END;
  334.     TRslRg = RECORD
  335.         iMin:                    INTEGER;
  336.         iMax:                    INTEGER;
  337.     END;
  338.     TRslRec = RECORD
  339.         iXRsl:                    INTEGER;
  340.         iYRsl:                    INTEGER;
  341.     END;
  342.     TGetRslBlk = RECORD
  343.         iOpCode:                INTEGER;
  344.         iError:                    INTEGER;
  345.         lReserved:                LONGINT;
  346.         iRgType:                INTEGER;
  347.         xRslRg:                    TRslRg;
  348.         yRslRg:                    TRslRg;
  349.         iRslRecCnt:                INTEGER;
  350.         rgRslRec:                ARRAY [0..26] OF TRslRec;
  351.     END;
  352.     TSetRslBlk = RECORD
  353.         iOpCode:                INTEGER;
  354.         iError:                    INTEGER;
  355.         lReserved:                LONGINT;
  356.         hPrint:                    THPrint;
  357.         iXRsl:                    INTEGER;
  358.         iYRsl:                    INTEGER;
  359.     END;
  360.     TDftBitsBlk = RECORD
  361.         iOpCode:                INTEGER;
  362.         iError:                    INTEGER;
  363.         lReserved:                LONGINT;
  364.         hPrint:                    THPrint;
  365.     END;
  366.     TGetRotnBlk = RECORD
  367.         iOpCode:                INTEGER;
  368.         iError:                    INTEGER;
  369.         lReserved:                LONGINT;
  370.         hPrint:                    THPrint;
  371.         fLandscape:                BOOLEAN;
  372.         bXtra:                    SInt8;
  373.     END;
  374.  
  375. PROCEDURE PrPurge;
  376.     {$IFC NOT GENERATINGCFM}
  377.     INLINE $2F3C, $A800, $0000, $A8FD;
  378.     {$ENDC}
  379. PROCEDURE PrNoPurge;
  380.     {$IFC NOT GENERATINGCFM}
  381.     INLINE $2F3C, $B000, $0000, $A8FD;
  382.     {$ENDC}
  383. PROCEDURE PrOpen;
  384.     {$IFC NOT GENERATINGCFM}
  385.     INLINE $2F3C, $C800, $0000, $A8FD;
  386.     {$ENDC}
  387. PROCEDURE PrClose;
  388.     {$IFC NOT GENERATINGCFM}
  389.     INLINE $2F3C, $D000, $0000, $A8FD;
  390.     {$ENDC}
  391. PROCEDURE PrintDefault(hPrint: THPrint);
  392.     {$IFC NOT GENERATINGCFM}
  393.     INLINE $2F3C, $2004, $0480, $A8FD;
  394.     {$ENDC}
  395. FUNCTION PrValidate(hPrint: THPrint): BOOLEAN;
  396.     {$IFC NOT GENERATINGCFM}
  397.     INLINE $2F3C, $5204, $0498, $A8FD;
  398.     {$ENDC}
  399. FUNCTION PrStlDialog(hPrint: THPrint): BOOLEAN;
  400.     {$IFC NOT GENERATINGCFM}
  401.     INLINE $2F3C, $2A04, $0484, $A8FD;
  402.     {$ENDC}
  403. FUNCTION PrJobDialog(hPrint: THPrint): BOOLEAN;
  404.     {$IFC NOT GENERATINGCFM}
  405.     INLINE $2F3C, $3204, $0488, $A8FD;
  406.     {$ENDC}
  407. FUNCTION PrStlInit(hPrint: THPrint): TPPrDlg;
  408.     {$IFC NOT GENERATINGCFM}
  409.     INLINE $2F3C, $3C04, $040C, $A8FD;
  410.     {$ENDC}
  411. FUNCTION PrJobInit(hPrint: THPrint): TPPrDlg;
  412.     {$IFC NOT GENERATINGCFM}
  413.     INLINE $2F3C, $4404, $0410, $A8FD;
  414.     {$ENDC}
  415. PROCEDURE PrJobMerge(hPrintSrc: THPrint; hPrintDst: THPrint);
  416.     {$IFC NOT GENERATINGCFM}
  417.     INLINE $2F3C, $5804, $089C, $A8FD;
  418.     {$ENDC}
  419. FUNCTION PrDlgMain(hPrint: THPrint; pDlgInit: PDlgInitUPP): BOOLEAN;
  420.     {$IFC NOT GENERATINGCFM}
  421.     INLINE $2F3C, $4A04, $0894, $A8FD;
  422.     {$ENDC}
  423. FUNCTION PrOpenDoc(hPrint: THPrint; pPrPort: TPPrPort; pIOBuf: Ptr): TPPrPort;
  424.     {$IFC NOT GENERATINGCFM}
  425.     INLINE $2F3C, $0400, $0C00, $A8FD;
  426.     {$ENDC}
  427. PROCEDURE PrCloseDoc(pPrPort: TPPrPort);
  428.     {$IFC NOT GENERATINGCFM}
  429.     INLINE $2F3C, $0800, $0484, $A8FD;
  430.     {$ENDC}
  431. PROCEDURE PrOpenPage(pPrPort: TPPrPort; pPageFrame: TPRect);
  432.     {$IFC NOT GENERATINGCFM}
  433.     INLINE $2F3C, $1000, $0808, $A8FD;
  434.     {$ENDC}
  435. PROCEDURE PrClosePage(pPrPort: TPPrPort);
  436.     {$IFC NOT GENERATINGCFM}
  437.     INLINE $2F3C, $1800, $040C, $A8FD;
  438.     {$ENDC}
  439. PROCEDURE PrPicFile(hPrint: THPrint; pPrPort: TPPrPort; pIOBuf: Ptr; pDevBuf: Ptr; VAR prStatus: TPrStatus);
  440.     {$IFC NOT GENERATINGCFM}
  441.     INLINE $2F3C, $6005, $1480, $A8FD;
  442.     {$ENDC}
  443. FUNCTION PrError: INTEGER;
  444.     {$IFC NOT GENERATINGCFM}
  445.     INLINE $2F3C, $BA00, $0000, $A8FD;
  446.     {$ENDC}
  447. PROCEDURE PrSetError(iErr: INTEGER);
  448.     {$IFC NOT GENERATINGCFM}
  449.     INLINE $2F3C, $C000, $0200, $A8FD;
  450.     {$ENDC}
  451. PROCEDURE PrGeneral(pData: Ptr);
  452.     {$IFC NOT GENERATINGCFM}
  453.     INLINE $2F3C, $7007, $0480, $A8FD;
  454.     {$ENDC}
  455. PROCEDURE PrDrvrOpen;
  456.     {$IFC NOT GENERATINGCFM}
  457.     INLINE $2F3C, $8000, $0000, $A8FD;
  458.     {$ENDC}
  459. PROCEDURE PrDrvrClose;
  460.     {$IFC NOT GENERATINGCFM}
  461.     INLINE $2F3C, $8800, $0000, $A8FD;
  462.     {$ENDC}
  463. PROCEDURE PrCtlCall(iWhichCtl: INTEGER; lParam1: LONGINT; lParam2: LONGINT; lParam3: LONGINT);
  464.     {$IFC NOT GENERATINGCFM}
  465.     INLINE $2F3C, $A000, $0E00, $A8FD;
  466.     {$ENDC}
  467. FUNCTION PrDrvrDCE: Handle;
  468.     {$IFC NOT GENERATINGCFM}
  469.     INLINE $2F3C, $9400, $0000, $A8FD;
  470.     {$ENDC}
  471. FUNCTION PrDrvrVers: INTEGER;
  472.     {$IFC NOT GENERATINGCFM}
  473.     INLINE $2F3C, $9A00, $0000, $A8FD;
  474.     {$ENDC}
  475.  
  476. {$ALIGN RESET}
  477. {$POP}
  478.  
  479. {$SETC UsingIncludes := PrintingIncludes}
  480.  
  481. {$ENDC} {__PRINTING__}
  482.  
  483. {$IFC NOT UsingIncludes}
  484.  END.
  485. {$ENDC}
  486.